﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace MaterialEditor
{
    class ConstantValueNode : Node
    {
        public NodeValue value;

        public override bool CanEdit
        {
            get { return true; }
        }

        private NodeValueType[][] _acceptTypes;
        public override NodeValueType[][] acceptTypes
        {
            get { return _acceptTypes; }
        }

        protected override Point ValuePosition
        {
            get { return new Point((int)position.X, (int)position.Y); }
        }

        public ConstantValueNode(int x, int y, NodeValue value)
            : base(x, y)
        {
            this.value = value;

            Color outputColor = Color.Black;
            switch (value.type)
            {
                case NodeValueType.ValueTexture:
                    outputColor = Color.Blue;
                    break;
                case NodeValueType.ValueFloat:
                    outputColor = Color.Red;
                    break;
            }

            output = new InputSlot(this, value, "");

            backgroundColor = System.Drawing.Color.Purple;
            string[] names = value.Value.GetType().ToString().Split(new char[] { '.' });
            string typename = names[names.Length - 1];
            Name = "Constant " + typename;
        }

        public override NodeValue Result
        {
            get { return value; }
        }

        public override object Clone()
        {
            return new ConstantValueNode((int)position.X, (int)position.Y, new NodeValue(this.value));
        }
    }
}
